home *** CD-ROM | disk | FTP | other *** search
- /* $VER: WWWworkbench.ibrx 1.0
- *Made by Andres Pääbo (c)1998 : paabo@bancom.net
- *
- */
- OPTIONS RESULTS
- fileonly=0 /*initialize */
- IF ~ SHOW('L', "rexxsupport.library") then addlib('rexxsupport.library', 0, -30,0)
-
- ADDRESS 'IBROWSE'
- brf='file://localhost/'
- cfg='IB'
-
- IF EXISTS('RAM:W4')=0 THEN
- ADDRESS COMMAND 'MAKEDIR RAM:W4'
- ENDIF
- W4config=OPEN('configfile', 'RAM:W4/W4'cfg'config.txt', 'Read')
- if W4config=0 then DO
- W4config=OPEN('configfile', 'WWWworkbench/W4config.txt', 'Read')
- if W4config=0 then DO
- screen="Workbench"
- width=100
- height=90
- spacing=3
- rowacross=3
- maxautosize=15
- FTPM.1='FTPMount:drwrname/public_html/'
- WWW.1='http://www.server.com/~myname/'
- FTPM.2=' '
- WWW.2=' '
- FTPM.3=' '
- WWW.3=' '
- FTPM.4=' '
- WWW.4=' '
- END
- END
-
- if W4config~=0 then DO WHILE~EOF('configfile')
- line = READLN('configfile')
- if INDEX(line,'*')~=0 then iterate
- if line='' then leave
- line2 = STRIP(line)
- interpret line2
- END
- CLOSE('configfile')
- /******END OF CONFIGURATION SECTION******/
-
- refresh=getclip('refresh')
- if refresh=2 then refresh='' /*just for below--clone*/
- newdrawer=getclip('newdrawer') /*turned to 1 if new, off at end of this, 2 is special case*/
-
- call setclip('screen',screen) /*needed by programs with requesters*/
-
- oldcurrdir=getclip('currdir')/*from another script*/
-
-
- 'QUERY TITLE'
-
- currdir=result
- if oldcurrdir~='' then currdir=oldcurrdir
- reqdir=currdir
-
- if newdrawer=1 then reqdir=getclip('oldreqdir')
- /*use old path since a new window has no filepath info*/
-
- refresh=getclip('refresh') /*keep in for clone*/
- /*if refresh='' then a support script has NOT told us not to
- *generate the requester but to go with the current directory and redo the page*/
-
- FILEREQUESTER:
- if refresh='' then DO
- ADDRESS COMMAND 'REQUESTFILE > "RAM:W4/resultstring" TITLE "Select DIRECTORY TO LOAD " NOICONS PUBSCREEN 'screen' DRAWER "'reqdir'" '
- IF rc=5 then call noload
- if rc=20 then call reqfail
- call open('resultstring','Ram:W4/resultstring',R)
- resultstring=readln('resultstring')
- resultstring=TRANSLATE(resultstring, ' ','"')
- resultstring=STRIP(resultstring)
- close('resultstring')
- currdir=resultstring
- if RIGHT(currdir,1)~='/' & RIGHT(currdir,1)~=':' then DO
- slashpos=LASTPOS('/',currdir)
- if slashpos=0 then slashpos=LASTPOS(':',currdir)
- file=SUBSTR(currdir,slashpos+1)
- currdir=LEFT(currdir,slashpos)
- fileonly=1
- END
- END
-
-
- /*detect if user loading an FTPMount directory*/
- FTPMtest=LEFT(currdir,9)
- IF FTPMtest = 'FTPMount:'then call remotehost
- ELSE DO
- shocurrdir=currdir
- urlstart="file://localhost/"
- END
-
-
- urlpath=urlstart||shocurrdir
- /***DONE****we have directory name and what we use for the url**********/
-
- /*deal with when user actually selects a file*/
- if fileonly=1 then call fileonly /*send file to viewing if file chosen in filerequester*/
-
- /*get a name for the generated thumnail document*/
- len=LENGTH(shocurrdir)
- shocurrdir2=LEFT(shocurrdir, len-1)
- nextpos=LASTPOS('/',shocurrdir2)
- if nextpos=0 then nextpos=LASTPOS(':',shocurrdir2)
- currdirnoroot=SUBSTR(shocurrdir2,nextpos+1)
- thumbname= currdirnoroot'-PICS.HTML'
-
- /*display stuff*/
- ws=(width + spacing+spacing)*rowacross
-
- /*get the directory files and extract information*/
- IF EXISTS('RAM:W4')=0 THEN
- ADDRESS COMMAND 'MAKEDIR RAM:W4'
- ENDIF
- empty=0
- ADDRESS COMMAND'List 'currdir' TO RAM:W4/FILELIST NOHEAD LFORMAT="%-30N %L %20A %D"'
- looklist=OPEN('lookfile', 'RAM:W4/FILELIST', 'Read')
- x=readln('lookfile')
- if x='' then empty=1
- close ('lookfile')
- /* sort alphabetically */
- ADDRESS COMMAND 'Sort RAM:W4/FILELIST TO RAM:W4/SORTEDLIST'
- close('lookfile')
-
- /*****large section below :go through list and generate the html document****/
-
- infilelist=OPEN('infile', 'RAM:W4/SORTEDLIST', 'Read')
- outfilelist=OPEN('outfile', 'RAM:W4/'thumbname, 'Write')
- W4topmenu=''
- insert=OPEN('topmenu', 'RAM:W4/W4topmenu',Read)
- if insert~=0 then W4topmenu=READLN('topmenu')
- CLOSE('topmenu')
-
- htmlopen='<HTML><TITLE>'currdir'</TITLE><BODY TEXT="#000000" BGCOLOR="#666666" TEXT="#FFFFFF" LINK="#9999FF" ALINK="#9999FF" VLINK="#9999FF"><CENTER> <A HREF= "'brf'WWWworkbench/W4new.ibrx"><IMG SRC="file://localhost/WWWworkbench/drawer.jpg" ></A> . <FONT SIZE=1>'currdir' . <A HREF="'brf'WWWworkbench/W4parent.ibrx"> <I>PARENT</A> .
- <A HREF="'brf'WWWworkbench/W4refresh.ibrx"> REFRESH</A> .
- <A HREF="'brf'WWWworkbench/W4clone.ibrx"> CLONE </I></A><BR><NOBR><A HREF= "'brf'WWWworkbench/W4delete.ibrx">Delete</A> . <A HREF= "'brf'WWWworkbench/W4copytoother.ibrx"> CopyTo</A> . <A HREF= "'brf'WWWworkbench/W4movetoother.ibrx"> MoveTo</A> . <A HREF= "'brf'WWWworkbench/W4rename.ibrx"> Rename</A> . <A HREF= "'brf'WWWworkbench/W4clonefiles.ibrx">Clone</A> . <A HREF= "'brf'WWWworkbench/W4makedir.ibrx"> MakeDir</A> . <A HREF= "'brf'WWWworkbench/W4deletedir.ibrx"> DelDir</A>. <A HREF= "'brf'WWWworkbench/W4arexx.ibrx"> Arexx</A> </FONT></NOBR></TD></TR></TABLE></NOBR><TABLE CELLSPACING='spacing'><TR>'
-
- WRITELN('outfile',htmlopen)
- /* go through the list one by one */
- if empty=1 then signal 'empty'
- rowcnt=rowacross
-
- n=0
- DO WHILE ~EOF('infile')
- line = READLN('infile')
- nextfile=LEFT(line, 30)
- nextfile=STRIP(nextfile)
- IF nextfile ~= "" THEN DO
- IF RIGHT(nextfile,5)='.INFO' THEN ITERATE
- IF RIGHT(nextfile,5)='.info' THEN ITERATE
- n=n+1
- date=RIGHT(line,9)
- date=TRANSLATE(date,' ','-')
- date=COMPRESS(date)
- filesize=SUBSTR(line, 31,16)
- filesize=COMPRESS(filesize)
- ln=LENGTH(filesize)
- if ln>2 then size=DELSTR(filesize, ln-2)
- ELSE size='0'
- if size='' then size='>1'
-
- htmlline='<TD WIDTH='width+3' ALIGN=CENTER VALIGN=TOP><A HREF="'urlpath||nextfile'" TARGET="_TOP"><IMG SRC="'urlpath||nextfile'" WIDTH='width' HEIGHT='height' ></A><BR><FONT SIZE=1 COLOR="#FFFFFF">'nextfile' <BR><FONT COLOR="#FFBB66">'size'k 'date' </FONT></TD>'
-
- if size>maxautosize then call maxauto
-
- /*special attention to html documents*/
- ext=RIGHT(nextfile,4)
- ext2=RIGHT(nextfile,5)
- SELECT
- WHEN ext='.HTM' then call htmldoc
- WHEN ext='.htm' then call htmldoc
- WHEN ext2='.html' then call htmldoc
- WHEN ext2='.HTML' then call htmldoc
- OTHERWISE NOP
- END
-
- if filesize='Dir' then call directory
-
- WRITELN('outfile',htmlline)
-
- if n=rowcnt then DO
- WRITELN('outfile','</TR><TR>');rowcnt=rowcnt+rowacross
- END
- END
- END
- /****html doc generated now close up**/
- EMPTY:
- htmlclose='</TR></TABLE ><BR></CENTER></BODY></HTML>'
- WRITELN('outfile',htmlclose)
- call CLOSE('infile')
- call CLOSE('outfile')
-
- /*outfile should be the html page. Now load it. But first determine to which frame, left or right*/
-
- 'GOTOURL file://localhost/Ram:W4/'thumbname
-
- /*cleanup*/
- ADDRESS COMMAND 'Delete "RAM:W4/FILELIST" QUIET'
- ADDRESS COMMAND 'Delete "RAM:W4/SORTEDLIST" QUIET'
- ADDRESS COMMAND 'Delete "RAM:W4/'thumbname'" QUIET'
- ADDRESS COMMAND 'Delete "RAM:W4/resultstring" QUIET'
- /*loose ends*/
- call setclip('refresh', '') /*job done restore reqfile op'n to '0' in cliplist*/
- call setclip('currdir','')
- call setclip('newdrawer',0)
- call setclip('oldreqdir',currdir)
- EXIT 0
-
- htmldoc:
- htmlline='<TD WIDTH='width+3' ALIGN=CENTER VALIGN=TOP><A HREF= "'urlpath||nextfile'"TARGET="_TOP"><IMG SRC="file://localhost/WWWworkbench/html.jpg" WIDTH='width' HEIGHT='height'></A><BR><FONT SIZE=1 COLOR="#FFFFFF">'nextfile'<BR><FONT COLOR="#FFBB66">'size' K 'date'<BR></FONT></TD>'
- return
-
- maxauto:
- htmlline='<TD WIDTH='width+3' ALIGN=CENTER VALIGN=TOP><A HREF= "'urlpath||nextfile'" TARGET="_TOP"><IMG SRC="file://localhost/WWWworkbench/bigpic.jpg" WIDTH='width' HEIGHT='height'></A><BR><FONT SIZE=1 COLOR="#FFFFFF">'nextfile'<BR><FONT COLOR="#FFBB66">'size' K 'date'<BR></FONT></TD>'
- return
-
-
- directory:
- htmlline='<TD WIDTH='width+3' ALIGN=CENTER VALIGN=TOP ><A HREF= "'brf'WWWworkbench/W4new.ibrx"><IMG SRC="file://localhost/WWWworkbench/drawer.jpg" WIDTH='width' HEIGHT='height'></A> <BR><FONT SIZE=1>'nextfile'</B></FONT></TD>'
- return
-
- remotehost:
- DO i=1 to 20 /*the 20 is arbitrary. most people will only have a couple*/
- Lftpmni=LENGTH(FTPM.i)
- compare=COMPARE(currdir,FTPM.i)
- if compare=0 then LEAVE
- if compare >Lftpmni then LEAVE
- END
- if compare=0 then shocurrdir=WWW.i
- if compare>Lftpmni then DO
- deeperstuff=SUBSTR(currdir, compare)
- shocurrdir=WWW.i||deeperstuff
- END
- if compare~=0 & compare~>Lftpmni then DO
- Say 'WWWworkbench could not find an http address for the FTPMount directory'
- Say ' that you selected. You need to establish it in your configuration'
- ADDRESS COMMAND 'WAIT 3'
- EXIT
- END
- urlstart='' /*we ask user to include the http:*/
- return
-
- fileonly:
- 'GOTOURL 'urlpath||file''
- EXIT 0
-
- noload:
- if newdrawer=2 then DO; call setclip('newdrawer',0);EXIT;END
- noload=OPEN('window', 'RAM:W4/window.html','Write')
- htmlwindow='<HTML><TITLE>'currdir'</TITLE><BODY><BR><BR><BR><CENTER><A HREF="'brf'WWWworkbench/WWWworkbench.ibrx"><FONT SIZE=2>OPEN a <IMG SRC="file://localhost/WWWworkbench/drawer.jpg"> DRAWER</A></FONT></CENTER></BODY></HTML>'
- WRITELN('window', htmlwindow)
- close('window')
- 'GOTOURL file://localhost/Ram:W4/window.html'
- EXIT
-
- reqfail:
- ADDRESS COMMAND 'C:REQUESTCHOICE >RAM:W4/resultstring
- "ALERT" "File Requester failed.Probably screen specified in config file non-existent. Fix config file . " "for now: put on Workbench?|CANCEL"'
- call open('resultstring','Ram:W4/resultstring',R)
- response=readln('resultstring')
- close('resultstring')
- if response=0 then EXIT
- if response=1 then DO; screen='Workbench';signal filerequester;END
- return